package aop10;

import org.aspectj.lang.JoinPoint;

public class Log {

    public void before(JoinPoint jp){
        Object proxy=jp.getThis();
        Object target=jp.getTarget();
        String methodName=jp.getSignature().getName();
        Object[] args=jp.getArgs();
        System.out.println("======代理"+proxy.getClass().getSimpleName()+"类，目标"+target.getClass().getSimpleName()+"类，"+methodName+"方法即将执行，参数个数"+args.length);
    }


    public void afterReturning(JoinPoint jp,Object r){
        Object proxy=jp.getThis();
        Object target=jp.getTarget();
        String methodName=jp.getSignature().getName();
        Object[] args=jp.getArgs();
        System.out.println("======代理"+proxy.getClass().getSimpleName()+"类，目标"+target.getClass().getSimpleName()+"类，"+methodName+"方法已经返回，返回值"+r);
    }


    public void afterThrowing(JoinPoint jp,Exception e){
        Object proxy=jp.getThis();
        Object target=jp.getTarget();
        String methodName=jp.getSignature().getName();
        Object[] args=jp.getArgs();
        System.out.println("======代理"+proxy.getClass().getSimpleName()+"类，目标"+target.getClass().getSimpleName()+"类，"+methodName+"方法已经出错，异常对象"+e);
    }

}
